import { request } from "@/utils/service"
import type * as Simul from "./types/simul"
import { AxiosResponse } from "axios"

/** 增 */
export function createSimulDataApi(data: FormData) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/simconfig/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteSimulDataApi(id: string) {
  return request({
    url: `/toksim/resource/simconfig/delete/${id}`,
    method: "post"
  })
}

/** 改 */
export function updateSimulDataApi(data: FormData) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/simconfig/edit",
    method: "post",
    data
  })
}

/** 查 */
export function getSimulDataApi(params: Simul.PageTableRequestData) {
  return request<Simul.SearchSimulTableResponseData>({
    url: "/toksim/resource/simconfig/search",
    method: "post",
    data: params
  })
}

/** 根据id查询资源库信息 */
export function getSimulInfoApi(id: string) {
  return request<Simul.SimulViewInfoResponseData>({
    url: `/toksim/resource/simconfig/get/${id}`,
    method: "get"
  })
}
/** 获取仿真资源类型 */
export function getSimulTypeOptionsApi() {
  return request<ApiResponseData<string[]>>({
    url: `/toksim/resource/simconfig/type/get`,
    method: "get"
  })
}

/** 下载仿真资源资源 */
export function downloadSimulApi(id: string) {
  return request<AxiosResponse>({
    headers: {
      "Content-Type": "application/octet-stream"
    },
    responseType: "blob",
    url: `/toksim/resource/simconfig/download/${id}`,
    method: "get"
  })
}

export function getResourceOptionsApi() {
  return request<Simul.SimulListResponseData>({
    url: "/toksim/resource/simconfig/list",
    method: "get"
  })
}
